

        var autoAppearing = disorderAnimate = chasingMouse = itemFollowingMove = null;
        var mouseX,mouseY,targetTop;
        $(document).ready(function(){
            mouseX = event.clientX || 0;
            mouseY = event.clientY || 0;
            $('body').mousemove(function(event){
                mouseX = event.clientX;
                mouseY = event.clientY;
                
            })
            $(document).ready(function(){
                $('main ul.nav li').click(function(){
                    $('main ul.nav li').removeClass('active');
                    $(this).addClass('active');
                })
            })
            chasingMouse = setInterval(function(){
                for(var n = 0;n < $('.needHover').length;n++){
                    var ele_h = $('.needHover')[n].offsetHeight;
                    var ele_w = $('.needHover')[n].offsetWidth;
                    var targetTop = mouseY - $('.needHover')[n].getBoundingClientRect().top;
                    var targetLeft = mouseX - $('.needHover')[n].getBoundingClientRect().left;
                    if((targetTop < 0 || targetTop > ele_h)){
                        

                        if($('.needHover')[n].className.indexOf('hoverFather') >= 0){
                                if($('.needHover')[n].className.indexOf('mouseOn') >= 0) continue;
                                $('.needHover:eq(' + n +')').addClass('mouseOn');
                        }else{
                            if($('.needHover')[n].className.indexOf('mouseOn') < 0) continue;
                            $('.needHover:eq(' + n +')').removeClass('mouseOn');
                        }
                    }else{//if((targetLeft > 0 && targetLeft < ele_w) && (targetTop > 0 && targetTop < ele_h))
                        if($('.needHover')[n].className.indexOf('mouseOn') >= 0) continue;
                        $('.needHover:eq(' + n +')').addClass('mouseOn');
                    }
                }
                
            },10);
            
            
            var autoAnimate = [];
            for(var a = 0;a < $('.autoAnimate').length;a++){
                $('.autoAnimate')[a].appears = false;
                autoAnimate.push($('.autoAnimate')[a]);
            }   
            
            autoAppearing = setInterval(function(){
                if(beginningDelay != null){
                    beginningDelay += 10;
                    if(beginningDelay <= animateDelayCount) return false;
                }
                var fixed = $('.navSide').css('height') == '50px'?true:false;
                for(var n = 0;n < autoAnimate.length;n++){
                    //var ele_top = autoAnimate[n].offsetTop;
                    var ele_h = autoAnimate[n].offsetHeight;
                    var window_h = window.innerHeight;
                    //var scrollTop = document.documentElement.scrollTop || document.body.scrollTop;
                    var window_top = autoAnimate[n].getBoundingClientRect().top;
                    fixed && (ele_h -= 50);
                    autoAnimate[n].className.indexOf('disorder') > 0 && (window_h -= 160);
                if(
                    
                    //ele_top + 160 < window_h + scrollTop
                    window_top <= window_h
                    &&
                    window_top > - ele_h
                    //ele_h + ele_top > scrollTop
                     ){
                         if(autoAnimate[n].className.indexOf('inview') <= 0){
                            $('.autoAnimate:eq(' + n + ')').addClass('inview');
                         }
                         autoAnimate[n].appears = true;
                    }else{
                        if(autoAnimate[n].className.indexOf('inview') >= 0){
                            $('.autoAnimate:eq(' + n + ')').removeClass('inview');
                         }
                            autoAnimate[n].appears = false;
                    } 
                }
            },10);
            
            for(var s = 0;s < $('.scrollItem').length;s++){
                var dataMoveDown = $('.scrollItem')[s].getAttribute('data-bottom-top').substring($('.scrollItem')[s].getAttribute('data-bottom-top').indexOf("(") - 1,$('.scrollItem')[s].getAttribute('data-bottom-top').length - 1).split(',');
                var dataMoveTop = $('.scrollItem')[s].getAttribute('data-top-bottom').substring($('.scrollItem')[s].getAttribute('data-top-bottom').indexOf("(") - 1,$('.scrollItem')[s].getAttribute('data-top-bottom').length - 1).split(',');
                $('.scrollItem')[s].moveDown = parseInt(dataMoveDown[1]);
                $('.scrollItem')[s].moveTop = parseInt(dataMoveTop[1]);
                var itemTop = $('.scrollItem')[s].getBoundingClientRect().top;
                    
                    if(itemTop >= window.innerHeight){
                        console.log('chu');
                        $('.scrollItem')[s].currentMoveVal = $('.scrollItem')[s].moveDown;
                        $('.scrollItem')[s].style.transform = 'translate(0,' + $('.scrollItem')[s].currentMoveVal + 'px)';
                    }else if(itemTop < window.innerHeight && itemTop > -$('.scrollItem')[s].offsetHeight){
                        if($('.scrollItem')[s].className.indexOf('contrary') >= 0){
                            $('.scrollItem')[s].currentMoveVal = $('.scrollItem')[s].moveDown + ($('.scrollItem')[s].moveTop - $('.scrollItem')[s].moveDown) * ((window.innerHeight - itemTop) / (window.innerHeight + $('.scrollItem')[s].offsetHeight));
                        }else{
                            
                            $('.scrollItem')[s].currentMoveVal = $('.scrollItem')[s].moveDown - ($('.scrollItem')[s].moveDown - $('.scrollItem')[s].moveTop) * ((window.innerHeight - itemTop) / (window.innerHeight + $('.scrollItem')[s].offsetHeight));
                        }
                       
                       $('.scrollItem')[s].style.transform = 'translate(0,' + $('.scrollItem')[s].currentMoveVal + 'px)';
                    }else{
                        $('.scrollItem')[s].currentMoveVal = $('.scrollItem')[s].moveTop;
                        $('.scrollItem')[s].style.transform = 'translate(0,' + $('.scrollItem')[s].currentMoveVal + 'px)';
                    }
                    $('.scrollItem')[s].updating = false;
            }
            $(window).scroll(function(){   //开始监听滚动条
                clearInterval(itemFollowingMove);
                
                itemFollowingMove = setInterval(function(){
                    
                    for(var f = 0;f < $('.scrollItem').length;f++){
                        //元素距离窗口顶部高度
                        var itemTop = $('.scrollItem')[f].getBoundingClientRect().top - $('.scrollItem')[f].currentMoveVal;
                        var destination;
                        
                        if(itemTop >= window.innerHeight){
                            destination = $('.scrollItem')[f].moveDown;
                            
                        }else if(itemTop < window.innerHeight && itemTop > -$('.scrollItem')[f].offsetHeight){
                            
                            if($('.scrollItem')[f].className.indexOf('contrary') >= 0){
                                destination = $('.scrollItem')[f].moveDown + ($('.scrollItem')[f].moveTop - $('.scrollItem')[f].moveDown) * ((window.innerHeight - itemTop) / (window.innerHeight + $('.scrollItem')[f].offsetHeight));
                            }else{
                                destination = $('.scrollItem')[f].moveDown - ($('.scrollItem')[f].moveDown - $('.scrollItem')[f].moveTop) * ((window.innerHeight - itemTop) / (window.innerHeight + $('.scrollItem')[f].offsetHeight));
                            }
                        }else{
                            destination = $('.scrollItem')[f].moveTop;
                        }
                        /*if($('.scrollItem')[f].currentMoveVal == destination){
                            continue;
                        }*/
                        $('.scrollItem')[f].updating = true;
                        //举例; start:189 > destination 188.5 => 188,再次通过新的判断变为189,下次进入又会变为188 以此类推无限反复循环
                        if($('.scrollItem')[f].currentMoveVal < destination){
                            if(destination - $('.scrollItem')[f].currentMoveVal <= 1){
                                $('.scrollItem')[f].currentMoveVal = destination;
                            }else{
                                $('.scrollItem')[f].currentMoveVal = $('.scrollItem')[f].currentMoveVal + Math.ceil((destination - $('.scrollItem')[f].currentMoveVal) / 10);
                            }
                        }else{
                            if($('.scrollItem')[f].currentMoveVal - destination <= 1){
                                $('.scrollItem')[f].currentMoveVal = destination;
                            }else{
                                $('.scrollItem')[f].currentMoveVal = $('.scrollItem')[f].currentMoveVal - Math.ceil(($('.scrollItem')[f].currentMoveVal - destination) / 10);
                            }
                        }
                        
                        $('.scrollItem')[f].style.transform = 'translate(0,' + $('.scrollItem')[f].currentMoveVal + 'px)';
                        if($('.scrollItem')[f].currentMoveVal == destination){
                            $('.scrollItem')[f].updating = false;
                        }
                    }
                    console.log('c');
                    for(var j = 0;j < $('.scrollItem').length;j++){
                        if($('.scrollItem')[j].updating) return false;
                    }
                    
                    clearInterval(itemFollowingMove);
                },10)
            })
        })
